package com.mls.fivedistrict.controller.backend;

import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.pojo.TaskCategory;
import com.mls.fivedistrict.server.TaskCategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Created by lixixi on 2018/4/3.
 */
@RestController
@RequestMapping("/api/manager")
public class TaskCategoryController {
    @Resource(name = "taskCategoryService")
    TaskCategoryService taskCategoryService;

    @GetMapping("/v1/taskCategorys")
    public ServiceResponse getTaskCategory() {
        List<TaskCategory> list = taskCategoryService.getTaskCategoryList();
        Map<String, String> maps = list.stream().collect(Collectors.toMap(TaskCategory::getName, TaskCategory::getValue));
        return ServiceResponse.createSuccessResponse(maps);
    }
}
